import Http from '@/utils/request';

/**
 * 获取优惠券列表
 * @param {*} pageNo 
 * @param {*} pageSize 
 * @param {*} params 
 */
export function getCouponList (pageNo, pageSize, params) {
    return Http.post(`/managerAPI/coupons/coupons/search-list/${pageSize}/${pageNo}`, params);
}

/**
 * 作废
 * @param {*} couponsId 
 */
export function cancelCoupon (couponsId) {
    return Http.post(`/managerAPI/coupons/coupons/del/${couponsId}`);
}

/**
 * 复制优惠券
 * @param {*} couponsId 优惠券id
 */
export function copyCoupon (couponsId) {
    return Http.get(`/managerAPI/coupons/coupons/copy/${couponsId}`);
}

/**
 * 添加优惠券
 * @param {*} params 参数
 */
export function addCoupon (params) {
    return Http.post('/managerAPI/coupons/coupons/add', params);
}

/**
 * 优惠券提交审核
 * @param {*} couponsId 
 */
export function auditCoupons (couponsId) {
    return Http.get(`/managerAPI/coupons/coupons/audit/${couponsId}`);
}

/**
 * 优惠券批量审核
 * @param {*} params 
 */
export function batchAuditList (params) {
    return Http.post('/managerAPI/coupons/coupons/auditList', params);
}

/**
 * 查询优惠券详细信息
 * @param {*} couponsId 
 */
export function getCouponDetail (couponsId) {
    return Http.get(`/managerAPI/coupons/coupons/detail/${couponsId}`);
}

/**
 * 编辑优惠券信息
 * @param {*} couponsId 
 * @param {*} params 
 */
export function editCoupon (couponsId, params) {
    return Http.post(`/managerAPI/coupons/coupons/edit/${couponsId}`, params);
}

export function getLog (couponsId) {
    return Http.get(`/managerAPI/coupons/OperationLog/query/${couponsId}`);
}

/**
 * 运营管理人员审核
 * @param {*} couponsId 
 */
export function operateAuditCoupon (params) {
    return Http.post(`/managerAPI/coupons/operate/audit/${params.couponsId}`, params);
}

/**
 * 运营管理人员批量审核
 */
export function operateBatchAudit (params) {
    return Http.post('/managerAPI/coupons/operate/auditList', params);
}

/**
 * 财务结算报表列表
 * @param {*} pageIndex 页码
 * @param {*} pageSize 页长
 */
export function getFinanceReportList (pageIndex, pageSize, params) {
    return Http.post(`/managerAPI/coupon-activity/finance/${pageSize}/${pageIndex}`, params);
}

/**
 * 结算
 */
export function doSettlement (id) {
    // 接口没整完
    return Http.get(`/managerAPI/coupon-activity/settle/${id}`);
}

/**
 * 获取优惠券数据统计
 * 接口报404 暂时放过
 * @param {*} pageIndex 
 * @param {*} pageSize 
 * @param {*} params 
 */
export function getDataStatistics (pageIndex, pageSize, params) {
    return Http.post(`/managerAPI/coupon-activity/data/${pageSize}/${pageIndex}`, params);
}

/**
 * 获取优惠券消息中心列表
 * @param {*} pageIndex 
 * @param {*} pageSize 
 * @param {*} params 
 */
export function getCouponMessageCenterList (pageIndex, pageSize, params) {
    return Http.post(`/managerAPI/coupon-activity/msg/${pageSize}/${pageIndex}`, params);
}

/**
 * 获取优惠券消息详情
 */
export function getCouponMessageDetail () {}

/**
 * 获取领券中心配置查询列表 0限时抢 1领券
 * @param {*} couponsType 
 */
export function getCouponCenterConfigList (couponsType) {
    return Http.get(`/managerAPI/coupons-center/coupons/center/query-list/${couponsType}`);
}

export function queryCouponList (pageIndex, pageSize, params) {
    return Http.post(`/managerAPI/coupons-center/coupons/center/query-coupons-list/${pageSize}/${pageIndex}`, params);
}

/**
 * 优惠券发放列表
 */
export function getQueryList (pageIndex, pageSize, params) {
    return Http.post(`/managerAPI/coupons-grant/query-list/${pageSize}/${pageIndex}`, params);
}

/**
 * 财务人员审核优惠券
 */
export function financeAuditCoupon (params) {
    return Http.post(`/managerAPI/coupons/finance/audit/${params.couponsId}`, params);
}

/**
 * 财务人员批量审核优惠券
 * @param {*} params 
 */
export function financeBatchAudit (params) {
    return Http.post('/managerAPI/coupons/finance/auditList', params);
}

export function getActivityLog (params) {
    return Http.get(`/managerAPI/coupon-activity/log/${params.pageSize}/${params.pageIndex}/${params.id}/${params.type}`);
}

/**
 * 获取优惠券消息中心详情
 * @param {*} id 
 */
export function getMessageCenterDetail (id, type) {
    return Http.get(`/managerAPI/coupon-activity/msg/${id}/${type}`);
}

export function forceEndActivity (id) {
    return Http.get(`/managerAPI/coupon-activity/over/${id}`);
}

/**
 * 显示领券活动详情
 */
export function showActivityDetail (id) {
    return Http.get(`/managerAPI/coupon-activity/show/${id}`);
}

/**
 * 领券活动 获取优惠券批次列表
 * @param {*} pageIndex 
 * @param {*} pageSize 
 * @param {*} params 
 */
export function queryCouponListByActivity (pageIndex, pageSize, params) {
    return Http.post(`/managerAPI/coupon-activity/coupons/center/query-coupons-list/${pageSize}/${pageIndex}`, params);
}

/**
 * 
 * @param {*} activityId 
 * @param {*} params 
 */
export function doEditActivity (activityId, params) {
    return Http.post(`/managerAPI/coupon-activity/edit/${activityId}`, params);
}

/**
 * 上传用户列表
 * @param {*} data 
 */
export function uploadUserList (url, data) {
    return Http.request({
        baseURL:'',
        url: url,
        method: 'post',
        headers: {
            Pragma: 'no-cache'
        },
        data: data,
        responseType: 'blob'
    });
}

/**
 * 查询商家信息
 */
export function getMerchant(){
    return Http.get(`/managerAPI/coupons/merchant`)
}
/**
 * 优惠券作废
 */
export function setCancellation(couponsCode){
    return Http.get(`/managerAPI/coupons-grant/cancellation/${couponsCode}`)
}
/**
 * 全流程查看-日志
 */
// /managerAPI/coupon-activity/log/{pageSize}/{pageIndex}/{id}/{type}
export function getCouponsLog(pageIndex, pageSize, id) {
    return Http.get(`/managerAPI/coupon-activity/log/${pageSize}/${pageIndex}/${id}/0`)
}
/**
 * 财务报表导出
 */
export function exportExcel(pageSize,pageIndex,params){
    return Http.request({
        baseURL:'',
        url: `/managerAPI/coupon-activity/export/${pageSize}/${pageIndex}`,
        method: 'post',
        headers: {
            Pragma: 'no-cache'
        },
        data: params,
        responseType: 'blob'
    });
} 

/**
 * 作废领券活动
 * @param {*} id 
 */
export function cancelActivity (id) {
    return Http.get(`/managerAPI/coupon-activity/invalid/${id}`);
}

/**
 * 查看用户发放明细
 * @param {*} pageIndex 
 * @param {*} pageSize 
 * @param {*} params 
 */
export function getBindingDetail (pageIndex, pageSize, params) {
    return Http.post(`/managerAPI/coupon-activity/binding-detail/${pageSize}/${pageIndex}`, params);
}

export function getFreeCountByActiveId (activityId) {
    return Http.get(`/managerAPI/coupon-activity/remain/${activityId}`);
}

export function doEditMessage (id, flag, params) {
    return Http.post(`/managerAPI/coupon-activity/msg/edit/${id}/${flag}`, params);
}

export function getCancellationCouponsLog (pageIndex, pageSize, couponsCode) {
    return Http.post(`/managerAPI/coupons-grant/cancellation/couponsLog/${pageSize}/${pageIndex}/${couponsCode}`)
}

export function getCancellationCouponDetail (couponsCode) {
    return Http.get(`/managerAPI/coupons-grant/cancellation/coupons/${couponsCode}`);
}
